package com.groupbuying.settleconsumer.common;

import com.groupbuying.settleconsumer.service.ChannelService;
import org.springframework.util.Assert;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 渠道策略工厂类,根据不同渠道设置不同的分账规则
 * author cuich
 * tar 调用方(OrderSettlementServiceImpl)
 * date 2019/12/2 10:16 上午
 * @apiGroup SettleConsumer
 * @apiVersion 1.0.0
 */
public class ChannelServiceStrategyFactory {

    private static Map<String,ChannelService> service = new ConcurrentHashMap<>();

    public static ChannelService getByChannelType (String payChannel){
        return service.get(payChannel);
    }

    public static void register(String payChannel,ChannelService channelService){
        Assert.notNull(payChannel,"payChannel can't be null");
        service.put(payChannel,channelService);
    }

}
